<%@ page import="com.actimind.actitime.beans.UserBean,
                 com.actimind.actitime.Keys"%><%@ page errorPage="/error.jsp" %><%

UserBean user = (UserBean)session.getAttribute(Keys.LOGGEDIN_USER_KEY);
if (user != null)
{
%>
<%@ taglib uri="/WEB-INF/at.tld" prefix="at" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<head>
    <title><bean:write name="title-prefix" scope="application"/> Add New User</title>

    <link rel="stylesheet" href="../css/at.css" type="text/css">

    <script language="JavaScript" src="../js/at.js"></script>
    <script language="JavaScript">
    function doSubmit(f)
    {
        /*if (!checkField(f.username, "Username is empty", "isNotEmpty"))
            return false;

        if (!checkField(f.password, "Password is empty", "isNotEmpty"))
            return false;

        if (!checkField(f.passwordRetype, "Retype Password is empty", "isNotEmpty"))
            return false;

        if (!checkField(f.firstName, "First name is empty", "isNotEmpty"))
            return false;

        if (!checkField(f.lastName, "Last name is empty", "isNotEmpty"))
            return false;

        if (isNotEmpty(f.email.value) &&
            !checkField(f.email, "Please specify a valid email address", "isEmailValid"))
            return false;

        trimAllTextFields(f);
        normalizeAllTextFields(f);*/

        return true;
    }

    </script>
</head>

<body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">

<jsp:include page="../top.jsp" flush="false">
    <jsp:param name="pageSection" value="administration" />
    <jsp:param name="pageAction" value="useradd" />
</jsp:include>

<html:form scope="session" action="/administration/useradd.do" method="post" onsubmit="return doSubmit(this)">



<input type="hidden" name="submitted" value="1" />

<table cellspacing="0" cellpadding="5" align="center" valign="top" border="0" bgcolor="#ffffff" width="770">
<tr>
    <td class="pagetitle">
        Add New User
    </td>
</tr>
<tr>
    <td class="pagetitle">
        <at:errors />
        <at:messages id="message" message="true">
            <span class="successmsg"><bean:write name="message"/></span>
        </at:messages>
    </td>
</tr>
<tr>
    <td>
        <table cellspacing="0" cellpadding="0" align="left" valign="top" border="0" bgcolor="#ffffff">
        <tr>
            <td colspan="4" class="formcomment">
                <span class="formfieldtitlereq">*</span> Indicates a required field.
            </td>
        </tr>
        <tr>
            <td colspan="4"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        <tr>
            <td colspan="4" class="formblocktitle">
                Specify Login Information
            </td>
        </tr>
        <tr>
            <td colspan="4"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        <tr>
            <td>
                <img height="1" width="20" src="../img/pixel.gif" />
            </td>
            <td>
                <table cellspacing="0" cellpadding="3" align="left" valign="top" border="0" bgcolor="#ffffff">
                <tr>
                    <td class="formfieldtitlereq">
                        *
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="username"><span class="errormsg">Username:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="username">Username:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:text property="username" style="width: 203px" maxlength="32" />
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitlereq">
                        &nbsp;
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="active"><span class="errormsg">Access:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="active">Access:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:select property="active">
                            <html:option value="true">enabled</html:option>
                            <html:option value="false">disabled</html:option>
                        </html:select>
                    </td>
                </tr>
                </table>
            </td>
            <td>
                <img height="1" width="20" src="../img/pixel.gif" />
            </td>
            <td>
                <table cellspacing="0" cellpadding="3" align="left" valign="top" border="0" bgcolor="#ffffff">
                <tr>
                    <td class="formfieldtitlereq">
                        *
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="password"><span class="errormsg">Password:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="password">Password:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:password property="password" style="width: 203px" maxlength="32" />
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitlereq">
                        *
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="password"><span class="errormsg">Retype Password:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="password">Retype Password:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:password property="passwordRetype" style="width: 203px" maxlength="32" />
                    </td>
                </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td colspan="4"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        <tr>
            <td colspan="4" class="formblocktitle">
                Specify Personal Information
            </td>
        </tr>
        <tr>
            <td colspan="4"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        <tr>
            <td>
                <img height="1" width="20" src="../img/pixel.gif" />
            </td>
            <td>
                <table cellspacing="0" cellpadding="3" align="left" valign="top" border="0" bgcolor="#ffffff">
                <tr>
                    <td class="formfieldtitlereq">
                        *
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="firstName"><span class="errormsg">First Name:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="firstName">First Name:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:text property="firstName" style="width: 203px" maxlength="32" />
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitlereq">
                        *
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="lastName"><span class="errormsg">Last Name:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="lastName">Last Name:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:text property="lastName" style="width: 203px" maxlength="32" />
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitlereq">
                        &nbsp;
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="middleName"><span class="errormsg">Middle Initial:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="middleName">Middle Initial:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:text property="middleName" style="width: 50px" maxlength="32" />
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitlereq">
                        &nbsp;
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="email"><span class="errormsg">E-mail Address:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="email">E-mail Address:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:text property="email" style="width: 203px" maxlength="255" />
                    </td>
                </tr>
                </table>
            </td>
            <td>
                <img height="1" width="20" src="../img/pixel.gif" />
            </td>
            <td>
                <table cellspacing="0" cellpadding="3" align="left" valign="top" border="0" bgcolor="#ffffff">
                <tr>
                    <td class="formfieldtitlereq">
                        &nbsp;
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="phone"><span class="errormsg">Phone:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="phone">Phone:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:text property="phone" style="width: 203px" maxlength="32" />
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitlereq">
                        &nbsp;
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="fax"><span class="errormsg">Fax:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="fax">Fax:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:text property="fax" style="width: 203px" maxlength="32" />
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitlereq">
                        &nbsp;
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="mobile"><span class="errormsg">Mobile:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="mobile">Mobile:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:text property="mobile" style="width: 203px" maxlength="32" />
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitlereq">
                        &nbsp;
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="otherContact"><span class="errormsg">Other Contact #:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="otherContact">Other Contact #:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:text property="otherContact" style="width: 203px" maxlength="32" />
                    </td>
                </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td colspan="4"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        <tr>
            <td colspan="4" class="formblocktitle">
               Adjust Overtime Tracking Settings
            </td>
        </tr>
        <tr>
            <td colspan="4"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        <tr>
            <td>
                <img height="1" width="26" src="../img/pixel.gif" />
            </td>
            <td align="left" valign="top" class="formfieldtitle" colspan="3">
               <table>
                 <tr>
                   <td>
                        <html:radio property="overtimeTracking" value="true" />
                   </td>
                   <td class="formfieldtitle">
                      Enable Overtime Tracking
                   </td>
                 </tr>
                 <tr>
                    <td>&nbsp;</td>
                    <td>
                       <span class="smallcomment">User will be able to track overtime. Section for entering overtime will be
                        <b>shown</b> on the Submit Time-Track interface.</span>
                    </td>
                 </tr>
                 <tr>
                    <td>&nbsp;</td>
                    <td class="formfieldtitle">
                       Workday Duration: <html:select property="workdayDuration" onchange="this.form.overtimeTracking[0].checked = true">
                       <%
                           for(int minute = 60; minute <= 24*60; minute+=30)
                            {
                               String hour = new Integer(minute / 60).toString();
                               String minLeft = (minute % 60 == 0) ? "00" : "30";
                       %>
                         <html:option value="<%=new Integer(minute).toString()%>"><%=hour +  ":" + minLeft%></html:option>
                       <%
                            }
                       %>
                       </html:select>
                    </td>
                 </tr>
                 <tr><td colspan="2"><img src="../img.pixel.gif" width="1" height="6" alt=""></td></tr>
                 <tr>
                   <td>
                       <html:radio property="overtimeTracking" value="false" />
                   </td>
                   <td class="formfieldtitle">
                        Disable Overtime Tracking
                   </td>
                 </tr>
                 <tr>
                    <td>&nbsp;</td>
                    <td>
                       <span class="smallcomment">User will not be able to track overtime. Section for entering overtime will be
                            <b>hidden</b> on the Submit Time-Track interface.</span>
                    </td>
                 </tr>
               </table>
            </td>
        </tr>
        <tr>
            <td colspan="4"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        <tr>
            <td colspan="4" class="formblocktitle">
                Assign Access Rights
            </td>
        </tr>
        <tr>
            <td colspan="4"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        <tr>
            <td>
                <img height="1" width="20" src="../img/pixel.gif" />
            </td>
            <td align="left" valign="top">
                <table cellspacing="0" cellpadding="3" width="100%" class="formbuttonpane" align="left" valign="top" border="0">
                <tr>
                    <td colspan="2" class="formblocktitle">
                        Time-Track Submission
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitle" width="20">
                        <html:checkbox property="submitTimeTrackGranted" />
                    </td>
                    <td class="formfieldtitle" width="90%">
                        Submit Time-Track
                    </td>
                </tr>
                <tr><td "formfieldtitle">&nbsp;</td></tr>

                <tr>
                    <td colspan="2" bgcolor="white"><img src="../img/pixel.gif" width="1" height="2"/></td>
                </tr>

                <tr>
                    <td colspan="2" class="formblocktitle">
                        Task Hierarchy Management
                    </td>
                </tr>

                <tr>
                    <td class="formfieldtitle" width="20">
                        <html:checkbox property="manageCustomersRightGranted" />
                    </td>
                    <td class="formfieldtitle">
                        Manage Customers
                    </td>
                </tr>

                <tr>
                    <td class="formfieldtitle" width="20">
                        <html:checkbox property="manageProjectsRightGranted" />
                    </td>
                    <td class="formfieldtitle">
                        Manage Projects
                    </td>
                </tr>

                <tr>
                    <td class="formfieldtitle" width="20">
                        <html:checkbox property="manageTasksRightGranted" />
                    </td>
                    <td class="formfieldtitle">
                        Manage Tasks
                    </td>
                </tr>

                </table>

            </td>
            <td>
                <img height="1" width="20" src="../img/pixel.gif" />
            </td>
            <td align="left" valign="top">

                <table cellspacing="0" cellpadding="3" width="100%" class="formbuttonpane" align="left" valign="top" border="0">

                <tr>
                    <td colspan="2" class="formblocktitle">
                        Reporting
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitle" width="20">
                        <html:checkbox property="generateReportsRightGranted" />
                    </td>
                    <td class="formfieldtitle" width="90%">
                        Generate Reports
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitle" width="20">
                        <html:checkbox property="prepareInvoiceDataRightGranted" />
                    </td>
                    <td class="formfieldtitle">
                        Prepare Invoice Data
                    </td>
                </tr>

                <tr>
                    <td colspan="2" bgcolor="white"><img src="../img/pixel.gif" width="1" height="2"/></td>
                </tr>

                <tr>
                    <td colspan="2" class="formblocktitle">
                        System Administration
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitle" width="20">
                        <html:checkbox property="manageUsersRightGranted" />
                    </td>
                    <td class="formfieldtitle">
                        Manage Users
                    </td>
                </tr>
<%--
                <tr>
                    <td class="formfieldtitle" width="20">
                        <html:checkbox property="manageSystemPreferencesRightGranted" />
                    </td>
                    <td class="formfieldtitle">
                        Manage System Preferences
                    </td>
                </tr>
--%>
                <tr>
                    <td class="formfieldtitle" width="20">
                        <html:checkbox property="manageBillingTypesRightGranted" />
                    </td>
                    <td class="formfieldtitle">
                        Manage Billing Types
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitle" width="20">
                        <html:checkbox property="manageCalendarPrefsGranted" />
                    </td>
                    <td class="formfieldtitle">
                        Manage Calendar Preferences
                    </td>
                </tr>
                </table>

            </td>
        </tr>
        <tr>
            <td colspan="4"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        </table>
    </td>
</tr>
<tr>
    <td align="center" class="formbuttonpane">
        <input type="submit" value="   Create User   " />
        <img height="1" width="100" src="../img/pixel.gif" />
        <input type="button" value="      Cancel      " onclick="if (confirm('Are you sure you want to cancel adding user?')) document.location.href='<html:rewrite href='userlist.do'/>'" />
    </td>
</tr>
</table>

</html:form>

</body>
</html>
<%
}
else
{
    response.sendRedirect("../login.do");
}
%>